import os
from config.configs import DATA_PATH,DOWNLOAD_PATH,DESKTOP_PATH
from tools.funciton import read_json_file,timestamp_switch_date,write_xlsx


def dingstock_express_order_export():
    li = []
    f = os.path.join(DESKTOP_PATH, 'orders.json')
    res = read_json_file(f)
    print(res)
    for i in res:
        if 'pickupCode' in i:
            li.append(
                [i['orderNo'], i['status'], i['senderName'], i['senderMobile'], i['senderProvince'] + i['senderCity'] +
                 i['senderArea'] + i['senderDetailAddress'], i['receiverName'], i['receiverMobile'],
                 i['receiverProvince'] + i['receiverCity'] + i['receiverArea'] + i['receiverDetailAddress'], i['type'],
                 i['pickupCode'],
                 i['provider'], timestamp_switch_date(int(i['createdAt']['$numberLong'])), i['payAmount']])
        else:
            li.append(
                [i['orderNo'], i['status'], i['senderName'], i['senderMobile'], i['senderProvince'] + i['senderCity'] +
                 i['senderArea'] + i['senderDetailAddress'], i['receiverName'], i['receiverMobile'],
                 i['receiverProvince'] + i['receiverCity'] + i['receiverArea'] + i['receiverDetailAddress'], i['type'],
                 '',
                 i['provider'], timestamp_switch_date(int(i['createdAt']['$numberLong'])), i['payAmount']])
    write_xlsx(['1'], li, '递潮订单')


# dingstock_express_order_export()
